package cn.mw.cmdb.entity;

import cn.mw.cmdb.service.ServiceChoose;
import cn.mw.cmdb.service.impl.InventoryWorkInfoServiceImpl;
import cn.mw.components.mongodb.anno.AutoId;
import cn.mw.components.mongodb.anno.CMDBProperty;
import cn.mw.components.mongodb.page.MWPage;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author shenwenyi
 * @Date 2024/4/26 15:44
 * @PackageName:cn.mw.cmdb.entity
 * @ClassName: InventoryWorkInfo 盘点任务
 * @Description: TODD
 * @Version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document("mw_cmdbmd_inventory_work_table")
public class InventoryWorkInfo implements ServiceChoose {

    private static final long serialVersionUID = 1L;

    @CMDBProperty
    @AutoId
    @Schema(description = "主键id")
    private String id;

    /**
     * 盘点任务名
     */
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "盘点任务名")
    private String workName;

    /**
     * 盘点机房
     */
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "盘点范围")
    private String machineRange;

    @CMDBProperty
    @Schema(description = "关联流程")
    private String process;

    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "盘点方式")
    private String inventoryType;

    /**
     * 任务状态
     */
    @CMDBProperty(searchType = PropertyTypeString.ID, keywordSearch = true)
    @Schema(description = "任务状态")
    private String workState;

    /**
     * 创建人
     */
    @CMDBProperty
    @Schema(description = "创建人")
    private String createUser;

    @CMDBProperty
    @Schema(description = "机构")
    private String org;

    @CMDBProperty
    @Schema(description = "用户组")
    private String group;

    @CMDBProperty
    @Schema(description = "机构")
    private List<List<Long>> orgIds;
    /**
     * 负责人
     */
    @Schema(description = "负责人")
    @CMDBProperty(searchType = PropertyTypeUser.ID)
    private List<String> principal;

    @Schema(description = "负责人名称")
    @Transient
    private String principalNames;

    @CMDBProperty
    @Schema(description = "关联流程id")
    private String processId;

    @CMDBProperty
    @Schema(description = "描述")
    private String describe;

    @CMDBProperty
    @Schema(description = "图片地址")
    private List<String> imgUrl;

    @CMDBProperty
    @Schema(description = "计划开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date plannedStartTime;
    @CMDBProperty
    @Schema(description = "计划结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date plannedEndTime;
    @CMDBProperty
    @Schema(description = "实际开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date actualStartTime;
    @CMDBProperty
    @Schema(description = "实际结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date actualEndTime;
    @CMDBProperty(searchType = PropertyTypeString.ID,keywordSearch = true)
    @Schema(description = "盘点结果")
    private String inventoryResult;
    @CMDBProperty
    @Schema(description = "创建人")
    protected String creator;

    @CMDBProperty
    @Schema(description = "创建时间")
    protected Date createDate;

    @CMDBProperty
    @Schema(description = "修改人")
    protected String modifier;

    @CMDBProperty
    @Schema(description = "修改时间")
    protected Date modificationDate;

    @Schema(description = "资产idList")
    @NotEmpty
    private List<String> assetsIdList;

    @Schema(description = "逻辑删除")
    @CMDBProperty(logicDel = true)
    protected Boolean delFlag = false;

    @Schema(description = "关联资产")
    @Transient
    private MWPage<InventoryWorkAssets> inventoryWorkAssetsList;

    @Schema(description = "盘点统计")
    @Transient
    private  Map<String, Integer> status2CountMap ;

    @Schema(description = "盘点进度")
    @Transient
    private  int  inventoryProgress ;

    @Schema(description = "移动端计划开始时间")
    @JsonFormat(pattern = "MM/dd HH:mm", timezone = "GMT+8")
    @Transient
    private Date  appPlannedStartTime;


    @Schema(description = "移动端计划结束时间")
    @JsonFormat(pattern = "MM/dd HH:mm", timezone = "GMT+8")
    @Transient
    private Date appPlannedEndTime;

    @Override
    public String getServiceId() {
        return InventoryWorkInfoServiceImpl.ID;
    }
}
